#!/bin/bash
#By Jagadish Manchala
# Script For Finding Out The memory Percentage

memusage=`top -n 1 -b | grep "Mem"`
MAXMEM=`echo $memusage | cut -d" " -f2 | awk '{print substr($0,1,length($0)-1)}'`
USEDMEM=`echo $memusage | cut -d" " -f4 | awk '{print substr($0,1,length($0)-1)}'`

USEDMEM1=`expr $USEDMEM \* 100`
PERCENTAGE=`expr $USEDMEM1 / $MAXMEM`%

echo "Total Memory: $MAXMEM KB, Used Memory: $USEDMEM KB, Used Memory Percentage: $PERCENTAGE"
